package com.lc.afbx.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lc.afbx.BaseApplication;
import com.lc.afbx.R;
import com.lc.afbx.conn.GetApiTeamMemberBaoDan;

import java.util.List;

/**
 * Created by Administrator on 2016/6/8.
 */
public class TeamBaoDanAdapter extends BaseAdapter {
    private List<GetApiTeamMemberBaoDan.Data> dataList;
    private LayoutInflater inflater;

    public TeamBaoDanAdapter(Context context, List<GetApiTeamMemberBaoDan.Data> dataList) {
        inflater = LayoutInflater.from(context);
        this.dataList = dataList;
    }

    @Override
    public int getCount() {
        return dataList.size();
    }

    @Override
    public Object getItem(int position) {
        return dataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.item_teambaodan, null);
            BaseApplication.ScaleScreenHelper.loadView((ViewGroup) convertView);

            holder.team_ordernum_tv = (TextView) convertView.findViewById(R.id.team_ordernum_tv);
            holder.insurance_type = (TextView) convertView.findViewById(R.id.insurance_type);
            holder.name = (TextView) convertView.findViewById(R.id.name);
            holder.starttime = (TextView) convertView.findViewById(R.id.starttime);
            holder.total = (TextView) convertView.findViewById(R.id.premium);
            holder.commission = (TextView) convertView.findViewById(R.id.commission);
            holder.rebate = (TextView) convertView.findViewById(R.id.rebate);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.team_ordernum_tv.setText(dataList.get(position).ordersn);
        holder.starttime.setText(dataList.get(position).starttime);
        holder.insurance_type.setText(dataList.get(position).insurance_type);
        holder.name.setText(dataList.get(position).name);
        holder.commission.setText(dataList.get(position).commission);
        holder.rebate.setText(dataList.get(position).rebate);
        holder.total.setText(dataList.get(position).total);

        return convertView;
    }

    class ViewHolder {
        //        "id": "1",
//                "name": "小明",
//                "starttime": "2016-06-07",
//                "total": "0.00",
//                "insurance_type": "交强险"
        TextView name, starttime, total, insurance_type, commission, rebate, team_ordernum_tv;
    }
}
